
function stringToHex(str) {
    var val = "unsigned char const buf[] = {\r\n";
	var cnt = 0;
    for (var i = 0; i < str.length; i++) {
        if (str.substring(i, i + 1) == "\n") {
            val += "0x";
            val += "0A, ";
        } else if (str.substring(i, i + 1) == "\r") {
            val += "0x";
            val += "0D, ";
        } else {
            val += "0x";
            val += str.charCodeAt(i).toString(16).toUpperCase();
            val += ", ";
        }
		cnt++;
		if(cnt% 15 == 0)
		{
		    val += "\r\n";
		}
    }
    val += "}";
    return val;
}